package aps

import glory.xxd.Utils
import org.json.JSONObject

class ChangeProductC2EController {

    def commentService

    /**
     *<Request>
     <Header>
     <TRANSACTIONID>aa103cfc-5a8b-4eec-8e18-6fe0dea91464</TRANSACTIONID>
     <MESSAGENAME>ChangeProductC2E</MESSAGENAME>
     <USERNAME>PDA001</USERNAME>
     </Header>
     <Body>
     <EQPID>1FB0101</EQPID>
     <LOTID>S5HA9698-P-020</LOTID>
     <DIESEQ>DIE1</DIESEQ>
     </Body>
     </Request>
     * @return
     */
    def index() {
        def EQPID = params.EQPID ?: ""
        def LOTID = params.LOTID ?: ""
        def DIESEQ = params.DIESEQ ?: ""

        def body = JSONObject.newInstance()
        body.put("EQPID", EQPID)
        body.put("LOTID", LOTID)
        body.put("DIESEQ", DIESEQ)

        String logUUID = Utils.getUUID();
        def header = JSONObject.newInstance()
        header.put("MESSAGENAME", "ChangeProductC2E")
        header.put("TRANSACTIONID", logUUID)
        header.put("USERNAME", 'PDA')

        def jsonAll = [Header: header, Body: body] //JSONObject.newInstance()
        //        jsonAll.put("Body",body)
        //        jsonAll.put("Header",header)
        def jsonRequest = JSONObject.newInstance()
        jsonRequest.put("Request", jsonAll)

        def json = commentService.getJsonByJsonForTopic2Queue(logUUID, jsonRequest)

        render json
    }
}
